// Dangerous? A bit, but I don't know how to duipai it.
#include<bits/stdc++.h>
#define rep(i,a,b) for (int i=(a),i##__END__=(b);i<=i##__END__;++i)
#define drep(i,a,b) for (int i=(a),i##__END__=(b);i>=i##__END__;--i)
using namespace std;
using ll = long long;

void ofile(string s){ // remember!!!
  freopen((s+".in").c_str(),"r",stdin);
  freopen((s+".out").c_str(),"w",stdout);
}

int n,m,w,V,p[100010],val[1000010];
struct seg{
  int l,r;
};
seg calc(int v,int a){
  // 2as>V^2-v^2
  if (!a)return v<=V?(seg){-1,-1}:(seg){0,w};
  else if (a<0){
    if (v<=V)return (seg){-1,-1};
    int t=v*v-V*V;
    int r=-2*a;
    int s=(t-1)/r;
    return (seg){0,min(s,w)};
  }else{
    if (v>V)return (seg){0,w};
    int t=V*V-v*v;
    int r=2*a;
    int s=t/r+1;
    return s>w?(seg){-1,-1}:(seg){s,w};
  }
}
struct node{
  int L,R;
  void read(){
    int d,v,a;
    cin>>d>>v>>a;
    seg t=calc(v,a);
    L=t.l,R=t.r;
    if (L!=-1){
      R+=d,L+=d;
      R=min(R,w);
      if (L>R)L=R=-1;
    }
    // cout<<L<<' '<<R<<endl;
  }
}a[100010];

void solve(){
  cin>>n>>m>>w>>V;
  rep(i,1,n)a[i].read();
  rep(i,1,m)cin>>p[i];
  rep(i,0,w+1)val[i]=0;
  // return ;
  rep(i,1,m)++val[p[i]];
  rep(i,1,w)val[i]+=val[i-1];
  int cnt=0;
  rep(i,1,n)if (a[i].L!=-1){
    int dec=!a[i].L?0:val[a[i].L-1];
    if (val[a[i].R]-dec)++cnt;
    else a[i].L=a[i].R=-1;
  }
  int nx=0;
  rep(i,1,n)if (a[i].L!=-1)a[++nx]=a[i];
  n=nx;
  cout<<cnt<<' ';
  cnt=0;
  sort(a+1,a+n+1,[&](node x,node y)->bool{
    if (x.L==-1)return 0;
    return x.R<y.R;
  });
  // while (n&&a[n].L==-1)--n;
  // cout<<"-------\n";
  // rep(i,1,n)cout<<a[i].L<<' '<<a[i].R<<'\n';
  p[0]=-1;
  int j=0,res=0;
  rep(i,1,n)if (a[i].L>p[j]){
    while (j<m&&p[j+1]<=a[i].R)++j;
    ++res;
  }
  cout<<m-res<<'\n';
}

int main(){
  ofile("detect");
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int tt;
  cin>>tt;
  while (tt--)solve();
  cout<<flush;
  return 0;
}